<template>
	<view class="container">

		<view>
			<u--form labelPosition="left" :model="form" :rules="rules" ref="form" labelWidth='100px'
				:labelStyle='labelStyle'>
				
				
				<view class="box">
					<u-form-item label="" prop="hfly" >
						<view class="textarea">
							<text class="title">恢复理由</text>
							<view class="tarea">
								<textarea
									style="background-color: #F6F6F6;color: #666666;font-size: 28rpx;border-radius: 8rpx; padding: 24rpx 0 24rpx 10rpx;"
									v-model="form.hfly" placeholder="请输入……" rows="3"></textarea>
							</view>
						</view>
					</u-form-item>
					
					
					<u-form-item label="恢复填报日期" prop="hftbrq" borderBottom @click="show=true">
						<u--input v-model="form.hftbrq" placeholder="恢复填报日期" disabledColor="#ffffff" disabled
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right" ></u-icon>
					</u-form-item>
					<u-calendar :show="show" @close='show=false'  @confirm="confirm"></u-calendar>
					<u-form-item label="实际恢复日期" prop="sjhfrq" borderBottom @click="show1=true">
						<u--input v-model="form.sjhfrq" placeholder="实际恢复日期" disabledColor="#ffffff" disabled
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right" ></u-icon>
					</u-form-item>
					<u-calendar :show="show1" @close='show1=false'  @confirm="confirm1"></u-calendar>
				</view>
			</u--form>
			<u-button type="primary" text="确认" @click="submit" class='but'></u-button>
		</view>
	</view>
</template>

<script>
	import {
		hfadd,
	} from '@/api/equipment'
	import {
		URL
	} from '@/api/request.js'
	export default {
		data() {
			return {
				show: false,
				show1: false,
				labelStyle: {
					color: '#666'
				},
				imageList: [], //本地上传图片数组
				list: [], //上传后端后返回的图片链接数组
				form: {
					xgfj: '',
					hfly: '',
					hftbrq: '',
					sjhfrq: '',
					
				},
				id: '',
				rules: {
					'hfly': {
						type: 'string',
						required: true,
						message: '不能为空',
						trigger: ['blur', 'change']
					},
					'hftbrq': {
						type: 'string',
						required: true,
						message: '不能为空',
						trigger: ['blur', 'change']
					},
					'sjhfrq': {
						type: 'string',
						required: true,
						message: '不能为空',
						trigger: ['blur', 'change']
					},
				

				},
			};
		},
		onLoad(option) {
			this.form.scssid = option.scssid
		},
		onShow() {
			
		},
		methods: {
			
			// 选择日期
			confirm(val) {
				this.form.hftbrq = val[0].replace(new RegExp("-", "gm"), "");
				this.show = false
			},
			confirm1(val) {
				this.form.sjhfrq = val[0].replace(new RegExp("-", "gm"), "");
				this.show1 = false
			},
			submit() {

				this.$refs.form.validate().then(res => {
					uni.$u.toast('校验通过')
					hfadd(this.form).then(res => {
						uni.$u.toast('编辑成功')
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
						}, 1000)

					})
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})

			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.container {
		padding: 0 24rpx;
		background-color: #f6f6f6;

		.title {
			font-size: 28rpx;
			font-weight: 500;
			line-height: 44rpx;
			padding: 20rpx 0;
		}

		.box {
			padding: 0rpx 48rpx;
			background-color: #fff;
			border-radius: 20rpx;
		}

		.textarea {
			
			.one {
				font-size: 28rpx;
				color: #999999;
			}

			.tarea {
				margin-top: 16rpx;
			}
		}
	}

	.but {
		margin: 30rpx 0;
	}
</style>
